require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
// var myPlayer;
var vm = new Vue({
    el:"#previewInfo",
    data:{
        name:"",
        type:"",
        list:{
            loginUid:"",
            resumeId:""
        },
        isInfoShow:false,
        preview:{}
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        this.list.resumeId=this.searchObject&&this.searchObject.resumeId;
        this.list.loginUid=this.searchObject&&this.searchObject.loginUid;
        this.type=this.searchObject&&this.searchObject.type;
        this.myResumePreview();

    },
    methods:{
        //后退
        getBack:function(){
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //简历预览
        myResumePreview:function(){
            var that=this;
            this.ajax({url:"/happyi/myResumePreview",data:that.list,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.preview=b.json.data;

                    if(that.type==1){
                        console.log(that.preview.imgSrc)
                        myPlayer.src(that.preview.imgSrc);
                        myPlayer.load();
                        myPlayer.play();
                    }
                }else{
                    vm.$refs.prompt.toast("获取信息失败！");
                }
            });
        },
        //视频暂停
        getVideoPause:function(){
            if(this.isInfoShow){
                var whereYouAt = myPlayer.currentTime();
                myPlayer.currentTime(whereYouAt);
                myPlayer.play();
            }else{
                myPlayer.pause();
            }
            this.isInfoShow=!this.isInfoShow;
        }

    }
    // ,watch:{
    //     preview:function(){
    //         if(this.type==1){
    //             this.$nextTick(function(){
    //                 myPlayer = videojs('my-video',{
    //                     loop:true,
    //                     controlBar: {
    //                         //fullscreenToggle:false,
    //                         volumeMenuButton:false
    //                     }
    //                 });
    //             });
    //         }
    //
    //     }
    // }
});
var myPlayer = videojs('my-video',{
    loop:true,
    controlBar: {
        //fullscreenToggle:false,
        volumeMenuButton:false
    }
});
